/*
 * @Description:
 * @Version: 1.0
 * @Autor: sun
 * @Date: 2021-02-18 15:00:15
 */
import Vue from 'vue';
import VueRouter from 'vue-router';
import shareInfo from '../assets/js/weixinShare';
Vue.use(VueRouter);

const routes = [

    {
        path: '/',
        name: 'index',
        component: () =>
            import ('../views/Index.vue'),

    },
    {
        path: '/main',
        name: 'main',
        component: () =>
            import ('../views/main.vue'),

    },
    {
        path: '/article',
        name: 'article',
        component: () =>
            import ('../views/article.vue'),
        children: [{
                path: '/article/1',
                component: () =>
                    import ('@/views/children/1.vue')
            },
            {
                path: '/article/2',
                component: () =>
                    import ('@/views/children/2.vue')
            },
            {
                path: '/article/3',
                component: () =>
                    import ('@/views/children/3.vue')
            },
            {
                path: '/article/4',
                component: () =>
                    import ('@/views/children/4.vue')
            },
            {
                path: '/article/5',
                component: () =>
                    import ('@/views/children/5.vue')
            },
            {
                path: '/article/6',
                component: () =>
                    import ('@/views/children/6.vue')
            },
            {
                path: '/article/7',
                component: () =>
                    import ('@/views/children/7.vue')
            }


        ]
    },

];
const router = new VueRouter({
    // mode: 'history',
    base: process.env.BASE_URL,
    routes
});

function handleFontSizeScale() {
    let realFz = parseFloat(window.getComputedStyle(document.getElementsByTagName('html')[0]).fontSize);
    let fz = Math.min(document.documentElement.clientWidth / 10, 54);
    let radio = realFz / fz;
    if (fz != realFz) {
        document.querySelector('html').style.cssText = `font-size:${(fz / radio).toFixed(1)}px`;
    }
}
handleFontSizeScale();
router.afterEach((to, from) => {
    const IS_PROD = ['production', 'prod'].includes(process.env.NODE_ENV);
    if (IS_PROD) {
        shareInfo.init({
            title: document.title,
            desc: '7大主题促销周正在加载，快来体验！',
            shareURL: 'http://www.nbd.com.cn/corp/202220520loveCd/dist/#/',
            img: 'https://nbd-luyan-1252627319.cos.ap-shanghai.myqcloud.com/nbd-console/9c8fe8d325ab6368e1a60f2212e0cd57.png'
        });
    }
});

export default router;